package com.xinzhi.controller;

import com.alibaba.fastjson.JSON;
import com.xinzhi.entity.need.OrderRequest;
import com.xinzhi.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class OrderController {

    /**
     * 点击支付生成新订单
     */
    @Autowired
    private OrderService orderService;
    @RequestMapping(value = "/goToShop",produces = "text/plain;charset=utf-8")
    @ResponseBody
    @CrossOrigin
    public String newOrder(@RequestBody List<OrderRequest> list){
        return JSON.toJSONString(orderService.newOrder(list));
    }
}
